DELETE FROM `arena_team` WHERE captainguid NOT IN (SELECT guid FROM `characters` );
DELETE FROM `arena_team_member` WHERE arenateamid NOT IN (SELECT arenateamid FROM `arena_team` );
DELETE FROM `arena_team_member` WHERE guid NOT IN (SELECT guid FROM `characters` );
DELETE FROM `arena_team_stats` WHERE arenateamid NOT IN (SELECT arenateamid FROM `arena_team` );
DELETE FROM `auctionhouse` WHERE itemowner NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_action` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
TRUNCATE TABLE `character_aura`;
DELETE FROM `character_gifts` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_homebind` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
TRUNCATE TABLE `character_instance`;
DELETE FROM `character_inventory` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_pet` WHERE ( owner ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_queststatus` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_reputation` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_social` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `character_spell` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
TRUNCATE TABLE `character_spell_cooldown`;
TRUNCATE TABLE `character_tutorial`;
DELETE FROM `corpse` WHERE ( player ) NOT IN ( SELECT guid FROM `characters` );
TRUNCATE TABLE `groups`;
TRUNCATE TABLE `group_instance`;
TRUNCATE TABLE `group_member`;
DELETE FROM `guild_bank_eventlog` WHERE ( guildid ) NOT IN ( SELECT guildid FROM `guild` );
DELETE FROM `guild_bank_item` WHERE ( guildid ) NOT IN ( SELECT guildid FROM `guild` );
DELETE FROM `guild_bank_right` WHERE ( guildid ) NOT IN ( SELECT guildid FROM `guild` );
DELETE FROM `guild_bank_tab` WHERE ( guildid ) NOT IN ( SELECT guildid FROM `guild` );
DELETE FROM `guild_eventlog` WHERE ( guildid ) NOT IN ( SELECT guildid FROM `guild` );
DELETE FROM `guild_member` WHERE ( guid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `guild_rank` WHERE ( guildid ) NOT IN ( SELECT guildid FROM `guild` );
TRUNCATE TABLE `instance`;
TRUNCATE TABLE `instance_reset`;
DELETE FROM `mail` WHERE (receiver ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `mail_items` WHERE (mail_id ) NOT IN ( SELECT id FROM `mail` );
DELETE FROM `item_text` WHERE (id ) NOT IN ( SELECT itemTextId FROM `mail` );
DELETE FROM `petition` WHERE (ownerguid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `petition` WHERE (petitionguid ) NOT IN ( SELECT guid FROM `item_instance` );
DELETE FROM `petition_sign` WHERE (ownerguid ) NOT IN ( SELECT guid FROM `characters` );
DELETE FROM `petition_sign` WHERE playerguid NOT IN (SELECT guid FROM `characters` );
DELETE FROM `petition_sign` WHERE petitionguid NOT IN (SELECT petitionguid FROM `petition` );
TRUNCATE TABLE `pet_aura`;
DELETE FROM `pet_spell` WHERE guid NOT IN (SELECT id FROM `character_pet` );
TRUNCATE TABLE `pet_spell_cooldown`;
DELETE FROM `item_instance` WHERE `guid` NOT IN (SELECT `item` FROM `character_inventory`) AND `guid` NOT IN (SELECT `itemguid` FROM `auctionhouse`) AND `guid` NOT IN (SELECT `item_guid` FROM `guild_bank_item`) AND `guid` NOT IN (SELECT `item_guid` FROM `mail_items`) AND `guid` NOT IN (SELECT `item_guid` FROM `character_gifts`);
DELETE FROM `item_instance` WHERE `owner_guid` NOT IN (SELECT `guid` FROM `character_inventory`) AND `owner_guid`<>'0';
DELETE FROM `character_inventory` WHERE `item` NOT IN (SELECT `guid` FROM `item_instance`);
DELETE FROM `auctionhouse` WHERE `itemguid` NOT IN (SELECT `guid` FROM `item_instance`);
DELETE FROM `guild_bank_item` WHERE `item_guid` NOT IN (SELECT `guid` FROM `item_instance`);
DELETE FROM `mail_items` WHERE `item_guid` NOT IN (SELECT `guid` FROM `item_instance`);
DELETE FROM `character_gifts` WHERE `item_guid` NOT IN (SELECT `guid` FROM `item_instance`);